var Kuo_UP_Aliyun = {
    SecretId:"",
    SecretKey:"",
    SecretHost:"",
    Bucket:"",
    Config:(config)=>{
        if(config ){
            if(config.SecretKey){
                Kuo_UP_Aliyun.SecretId = config.SecretId;
            }
            if( config.SecretKey){
                Kuo_UP_Aliyun.SecretKey = config.SecretKey;
            }
            if(config.SecretHost){
                Kuo_UP_Aliyun.SecretHost = config.SecretHost;
            }
            if(config.Bucket){
                Kuo_UP_Aliyun.Bucket = config.Bucket;
            }
        }

        return Kuo_UP_Aliyun;

    },OSSUpload:async (file,file_)=>{

    },Upload:async (file,file_)=>{
        var neirong = FS.readFileSync(file);
        var  SHUJU = {
            body:neirong,
            method:"PUT"
        };
        var $cmd5 =  CRYPTO.createHash('md5').update(neirong).digest('base64');
        var $shijia = Mode("Tools").UTC();
        var $string_to_sign ="PUT\n"+
            $cmd5+"\n" +
            "application/octet-stream\n"+
            $shijia+"\n" +
            "/"+Kuo_UP_Aliyun.Bucket +file_;
        var headerEncoding = 'utf-8';
        var $qianm = CRYPTO.createHmac('sha1', Kuo_UP_Aliyun.SecretKey ).update(Buffer.from($string_to_sign, headerEncoding)).digest('base64');
        SHUJU.headers = {
            "Content-MD5":$cmd5,
            "Content-Type":"application/octet-stream",
            "Authorization":"OSS "+Kuo_UP_Aliyun.SecretId+":"+$qianm,
            "Date": $shijia,
            "Host": Kuo_UP_Aliyun.SecretHost,
            "Content-Length": Buffer.byteLength(neirong)
        }
        var fan = await POST("https://"+Kuo_UP_Aliyun.SecretHost+file_,null,SHUJU);
        if(fan !== false && fan == ""){
            return  true;
        }
        return  false;
    }
}
module.exports = Kuo_UP_Aliyun;